package com.bnz.portal.controller;

import com.bnz.portal.entity.ContentEntity;
import com.bnz.portal.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class portalController {
    @Autowired
    private ContentService contentService;
    // /就表示访问默认的视图页面
    @GetMapping({"/","/index.html"})
    // 1. 查询所有广告
    public String index(Model model){
        // 1. 查询所有广告
        List<ContentEntity> list = contentService.findAll();
        // 2. 将查询到的内容放到model中
        model.addAttribute("contentList",list);
        return ("index");
    }
}
